require(['./config'], () =>{
    require(['header','footer'],()=>{

        class Register {
            constructor (){
                        this.registerName()
                       
            }
            registerName(){
                $('#actual_username').blur(function(){
                    // console.log(123)
                    let reg = /^1[3-8]\d{9}$/,
                        username = $('#actual_username').val()
                         username = parseInt (username)
                         console.log(username)
                       if(username){
                            if(reg.test(username)){
                                let names = localStorage.getItem('name')
                                   if(names){
                                    names = JSON.parse(names)
                                    names.forEach( name =>{
                                        if (username === name){
                                            $('#already_exist_name').html('您输入的手机已存在') 
                                        }else{
                                            $('#already_exist_name').html('') 
                                        }
                                    })
                                   }else{
                                    $('#already_exist_name').html('')   
                                   }
                                // $('#already_exist_name').html('')  
                            }else{
                                $('#already_exist_name').html('请输入正确的手机号') 
                            }
                        // $('#already_exist_name').html('') 
                        console.log(123)
                       }else{
                        $('#already_exist_name').html('不能为空')
                           console.log(456)
                       }
                       
                    //    let names = localStorage.getItem('name')
                    //    if(names){
                    //     names = JSON.parse(names)
                    //     names.forEach( name =>{
                    //         if (username === name){
                    //             $('#already_exist_name').html('您输入的手机已存在') 
                    //         }else{
                    //             $('#already_exist_name').html('') 
                    //         }
                    //     })
                    //    }else{
                    //     $('#already_exist_name').html('')   
                    //    }
                })
                this.registerPassword()
            }
            registerPassword(){
                
                   
                    $('#actual_password').blur (function(){
                        let password = $('#actual_password').val(),
                            ret = /^\w{6,10}$/
                            // console.log(password)
                        if(password){
                             if(ret.test(password)){
                                    $('#already_exist_password').html('') 
                                }else{
                                    $('#already_exist_password').html('密码不符合规则请重新输入')
                            
                                }
                            // $('#already_exist_password').html('')
                        }else{
                            $('#already_exist_password').html('不能为空')
                             
                        }
                        $('#actual_password_ture').blur(function(){
                            let truePassword = $('#actual_password_ture').val()
                            //  console.log(truePassword)
                                if(truePassword === password){
                                    $('#false_password').html('')
                                }else{
                                    $('#false_password').html('密码不一致')
                                }
                            })
                       
                    })   
                    
                    
                    this.sureRegister()
             }
             sureRegister(){
                $('#checkbox_input') 
                .on ('change',function (){
                    if(this.checked){
                        console.log(123)
                       
                    }else{
                        console.log(456) 
                    }
                })
                    // .checked?console.log(123) : console.log(456)
                //  $('#input_sureRegister').on('click',()=>{
                    $('btn_sureRegister').on('click',()=>{
                     
                        console.log(000)

                     }) 
                       

                //      })
                      
                    // if($('#already_exist_name').html('') &  $('#already_exist_password').html('') &  $('#false_password').html('') & $('#checkbox').checked){

                    //     let username  = $('#actual_username').val(),
                    //         password  = $('#actual_password').val()
                    //     localStorage.setItem('name',JSON.stringify([{
                    //         username : username,
                    //         password : password
                    //     }
                            
                    //     ]))
                    //     alert('注册成功即将跳转到登录页面')
                    //     location.href = '/html/login.html';

                    //  }else{

                    //      alert('您的注册信息有误')
                    //      console.log($('#already_exist_name').val())
                    //      console.log($('#already_exist_password').val())
                    //      console.log($('#false_password').val())
                    //      console.log($('#checkbox').checked)

                    //  }




                //  })
                        







             }




    }
        new Register ()
    })
})